﻿using System;
using System.Web.Mvc;

public static class CustomHtmlHelper
{
    public static string ValidationMessageText(this HtmlHelper helper, string name)
    {
        if (helper.ViewData.ModelState[name] == null || 
            helper.ViewData.ModelState[name].Errors == null ||
            helper.ViewData.ModelState[name].Errors.Count < 1 )
        {
            return String.Empty;
        }

        return helper.ViewData.ModelState[name].Errors[0].ErrorMessage;
    }

}